﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Tanks
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        
        Bitmap canvas = new Bitmap(800, 600);
        Graph g;
        Game game = Game.Instance();
        private void Form1_Load(object sender, EventArgs e)
        {
            this.
            g = new Graph(canvas, game.Grid, game.FieldWidth, game.FieldHeight);
            game.randomFillMap();
            
        }

        private void Form1_KeyPress(object sender, KeyEventArgs e)
        {
            game.KeyList[(int)e.KeyCode] = true;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            g.redraw();
            field.Image = canvas; lb.Items.Clear();
            foreach (Tank t in game.AllTanks)
            {
                lb.Items.Add(t.Health.ToString());
            }
        }

        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            game.KeyList[(int)e.KeyCode] = false;
            //lb.Items.Add((int)e.KeyCode);
        }

        private void field_Click(object sender, EventArgs e)
        {

        }
        
    }
}
